<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>扩展运算符</title>
</head>
<body>
<p>拓展运算符（...）用于取出参数对象所有可遍历属性然后拷贝到当前对象。</p>
<script>
    let user = {name: "仁康", age: 18};
    // 对象复制
    let renkang = {...user}; // 相当于 let renkang = {name: "仁康", age: 18};
    console.log(renkang);

    // 对象的属性合并
    let hobby = "girl";
    let renkang2 = {...user, hobby};
    // let renkang2 = {...user,hobby,address:"郑州"};
    console.log(renkang2);

    // ... 可以和解构数组组合属性
    let arr = [1, 2, 3, 4, 5];
    let [x, y, ...z] = arr;
    // x=1  y=2  z=[3,4,5]
    console.log(x, y, z);

</script>
</body>
</html>